package sg.edu.nus.iss.club.gui;
import java.awt.Button;
import java.awt.Panel;
import java.awt.event.*;
import java.util.*;
import sg.edu.nus.iss.club.*;
import sg.edu.nus.iss.club.util.*;
import javax.swing.*;

public class AddMemberDialog extends OkCancelDialog {

	ClubApplication parent;
	
	JTextField JtfSurName;
	JTextField JtfFirstName;
	JTextField JtfSecondName;
	
	
	public AddMemberDialog(ClubApplication parent) {
		
		super(parent.getClubWindow(), "Add Member");
		this.parent = parent;
	}
	

    public JPanel createFormPanel () {
    	JPanel formPanel = new JPanel();
    	JtfSurName = new JTextField(20);
    	JtfFirstName= new JTextField(20);
    	JtfSecondName= new JTextField(20);
    	formPanel.add(JtfSurName);
    	formPanel.add(JtfFirstName);
    	formPanel.add(JtfSecondName);
    	
    	
    	return formPanel;
    	
    }

    public boolean performOkAction () {
    	if (emptyInput()) {
    		return false;
    	}else{
    		//System.out.println(JtfSurName.getText() + "::" + JtfFirstName.getText() + "::" +  JtfSecondName.getText());
    		parent.addMember(JtfSurName.getText(), JtfFirstName.getText(), JtfSecondName.getText());
    		return true;
    	}
    }
    
    private boolean emptyInput(){
    	if(JtfSurName.getText()!=null && JtfSurName.getText().length()>0){
    		
    	
    		if(JtfFirstName.getText()!=null && JtfFirstName.getText().length()>0){
    			return false;
    		}
    	}
    	
    	return true;
    }
	
	
}
